package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 商家所得 相关枚举
 */
public class ShopGainsConstant {


    /**
     * 0普通商品，1服务商品
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum GoodsType implements IntegerEnum<Integer> {

        COMMON_GOODS(0, "普通商品"),

        SERVICE_GOODS(1, "服务商品"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        GoodsType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ShopGainsConstant.GoodsType getByCode(int code) {
            for (ShopGainsConstant.GoodsType value : ShopGainsConstant.GoodsType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 账单类型（0，支出，1收入）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum BillType implements IntegerEnum<Integer> {

        EXPENDITURE(0, "支出"),

        INCOME(1, "收入"),
        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        BillType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ShopGainsConstant.BillType getByCode(int code) {
            for (ShopGainsConstant.BillType value : ShopGainsConstant.BillType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 收入模式：0、非收入，1、销售商品，2、销售服务，3、运费所得
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum InnerMode implements IntegerEnum<Integer> {
        EMPTY(0, "非收入"),

        SALE_GOODS(1, "销售商品"),

        SALE_SERVICE(2, "销售服务"),

        FREIGHT(3, "运费所得"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        InnerMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ShopGainsConstant.InnerMode getByCode(int code) {
            for (ShopGainsConstant.InnerMode value : ShopGainsConstant.InnerMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public static String getMsgByCode(int code) {
            InnerMode[] innerModes = values();
            for (InnerMode innerMode : innerModes) {
                if (innerMode.getCode().equals(code)) {
                    return innerMode.getMsg();
                }
            }
            return null;
        }
    }

    /**
     * 支出模式：（0，非支出，1提现）
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum OuterMode implements IntegerEnum<Integer> {
        EMPTY(0, "非支出"),
        DRAW_MONEY(1, "兑换"),

        ;

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OuterMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ShopGainsConstant.OuterMode getByCode(int code) {
            for (ShopGainsConstant.OuterMode value : ShopGainsConstant.OuterMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }

        public static String getMsgByCode(int code) {
            OuterMode[] outerModes = values();
            for (OuterMode outerMode : outerModes) {
                if (outerMode.getCode().equals(code)) {
                    return outerMode.getMsg();
                }
            }
            return null;
        }
    }





}
